import sys
import os
import threading
import multiprocessing
import os


def fib1(n):
    if n <= 2:
        return 1
    else:
        return fib1(n-1) + fib1(n-2)


def fib2(n):
    if n <= 2:
        return 1
    else:
        left = right = 1
        n -= 2
        for i in range(n):
            left, right = right, left+right
        return right


def thread_caller(number=2, n=10):
    threads = []
    for i in range(number):
        t = threading.Thread(target=fib1, args=(n,))
        t.start()
        threads.append(t)
    for t in threads:
        t.join()


def process_caller(number=2, n=10):
    procs = []
    for i in range(number):
        p = multiprocessing.Process(target=fib1, args=(n,))
        p.start()
        procs.append(p)
    for p in procs:
        p.join()


if __name__ == '__main__':
    if len(sys.argv) != 3:
        print('usage: %s thread|process n' % os.path.basename(sys.argv[0]))
        exit(1)

    kind = sys.argv[1]
    n = int(sys.argv[2])
    number = 2
    if kind == 'thread':
        thread_caller(number, n)
    elif kind == 'process':
        process_caller(number, n)
